package com.zsx.add;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
//将增强类托管给spring
@Component
public class AddWay {
    /*
     *建立切入点组
     */
    @Pointcut("execution(* com.zsx.mapper.imp.DoTeacherImp.insert())")
    void insert(){

    }
    @Pointcut("execution(* com.zsx.mapper.imp.DoTeacherImp.delete())")
    void delete(){

    }
    @Pointcut("execution(* com.zsx.mapper.imp.DoTeacherImp.update())")
    void update(){

    }
    @Pointcut("execution(* com.zsx.mapper.imp.DoTeacherImp.select())")
    void select(){

    }
    @Before("delete()")
    @AfterReturning("delete()")
    public void quanXian(){
        System.out.println("我执行权限校验功能");
    }
    public void log(){
        System.out.println("我执行日志功能");
    }
    @Around("insert()")
    public void huanRao(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        quanXian();
        proceedingJoinPoint.proceed();
        log();
    }
    @After("update()")
    public void last(){
        System.out.println("我执行了最终增强");
    }
    @AfterThrowing("select")
    public void err(){
        System.out.println("我是一个异常处理增强");
    }

}
